https://leetcode.cn/problems/beautiful-arrangement/description/
class Solution {
public:
    int  ret,_n;
    bool check[17];
    void dfs(int pos)
    {
        if(pos==_n+1)
        {
            ret++;
            return ;
        }
        for(int i=1;i<=_n;i++)
        {
            if(!check[i]&&(i%pos==0||pos%i==0))
            {
                check[i]=true;
                dfs(pos+1);
                //恢复现场
                check[i]=false;

            }
        }
    }

    int countArrangement(int n) {
        _n=n;
        dfs(1);
        return ret;
    }
};